/**
 * Package:cn.tst.test;
 * $Id: Node.java,v 1.2 2008/12/02 03:01:26 yangc Exp $
 * Copyright(c) 2001-2005 www.afteryuan.com
 */
package com.afteryuan.server.support.astar;

import com.afteryuan.server.support.Point;

/**
 * Node
 * 地图中的节点
 * 按照A*算法：h=f+g,
 * h为从起点A到终点B的评估耗费，
 * g为从起点A，沿着产生的路径，移动到网格上指定方格的移动耗费,
 * f为从网格上那个方格移动到终点B的预估移动耗费
 * <p/>
 * <p><a href="Node.java.html"><i>View Source</i></a></p>
 *
 * @author <a href="mailto:afteryuan@afteryuan.com">$Author: yangc $</a>
 * @version $Revision: 1.2 $
 */
public class Node {
    //从起点A沿着产生的路径移动到当前节点的预估移动耗费
    public int costFromStart = 0;
    //从当前节点移动到终点B的预估移动耗费
    public int costToGoal = 0;
    //从起点A到终点B的评估耗费
    public int totalCost = 0;
    public Point location = null;
    public Node parent;

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Node node = (Node) o;

        if (location != null ? !location.equals(node.location) : node.location != null) return false;

        return true;
    }

    public int hashCode() {
        return (location != null ? location.hashCode() : 0);
    }

    public String toString() {
        return "Node{" +
                "costFromStart=" + costFromStart +
                ", costToGoal=" + costToGoal +
                ", totalCost=" + totalCost +
                ", location=" + location +
                '}';
    }

}
